package cn.wch.ch934xlib.chip;

import android.hardware.usb.UsbDevice;

import androidx.annotation.NonNull;

public class ChipValidUtil {
    //判断该设备是否是目标设备
    public static boolean isValid(@NonNull UsbDevice usbDevice){
        ChipType[] chipTypes = ChipType.values();
        for (ChipType chipType : chipTypes) {
            if(usbDevice.getVendorId()==chipType.getVid() && usbDevice.getProductId()==chipType.getPid()){
                return true;
            }
        }
        return false;
    }

    public static ChipType getChipType(@NonNull UsbDevice usbDevice){
        ChipType[] chipTypes = ChipType.values();
        for (ChipType chipType : chipTypes) {
            if(usbDevice.getVendorId()==chipType.getVid() && usbDevice.getProductId()==chipType.getPid()){
                return chipType;
            }
        }
        return null;
    }
}
